<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
                template="./admin.xhtml"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://xmlns.jcp.org/jsf/core">

    <ui:define name="content">
        <div id="page-wrapper">
            <h:form>
                <p:growl id="msgUpdatePost" life="2000" showDetail="true" />
                <div class="row">
                    <div class="col-md-12">
                        <p:outputLabel for="title" value="#{msg['title']}: " /><p:spacer/>
                        <h:inputText id="title" styleClass="form-control width-100" value="#{postManagement.selectedPost.title}" />
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-12">
                        <p:outputLabel for="category" value="#{msg['category']}: " /><p:spacer/>
                        <h:selectOneMenu id="category" value="#{postManagement.selectedPost.category}" 
                                         styleClass="form-control selectOneMenu" required="true">
                            <f:converter converterId="categoryConverter" />
                            <f:selectItems value="#{postManagement.categorys}" var="cate"
                                           itemValue="#{cate}" itemLabel="#{cate.categoryName}" />
                        </h:selectOneMenu> 
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-2">
                        <p:outputLabel for="detail" value="#{msg['content']}: " />
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-12">
                        <p:editor id="detail" value="#{postManagement.selectedPost.content}" styleClass="width-100" height="500" />
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-12">
                        <p:outputLabel for="attach" value="#{msg['attachment']}: " />
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-12">
                        <p:fileUpload id="attach" fileUploadListener="#" mode="advanced" dragDropSupport="true"
                                      multiple="true" sizeLimit="100000" fileLimit="3" />
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-12">
                        <h:commandButton styleClass="btn btn-primary float-right" value="#{msg['publish']}" 
                                         action="#{postManagement.createPost(evt)}" />
                    </div>
                </div>
            </h:form>
        </div>
    </ui:define>

</ui:composition>
